#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
int e[20][20];
int a[20];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;
    for (int i = 0; i < n; i++)a[i] = i;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)cin >> e[i][j];
    int best = INT_MAX;
    do {
        //A[a[0]] A[a[1]]....A[a[n-1]]
//        copy(a,a+4,ostream_iterator<int>(cerr," "));
//        cerr<<endl;
        int tot = 0;
        for (int i = 0; i < n; i++) {
            // A[a[i]]A[a[(i+1)%n]]
            tot += e[a[i]][a[(i + 1) % n]];
        }
        best = min(best, tot);
        //
    } while (next_permutation(a + 1, a + n));
    cout << best << endl;
    return 0;
}